#include <lcd/qc1602a.h>

#include <arduino/Arduino.h>
#include <LiquidCrystal/LiquidCrystal.h>


#define IMPL reinterpret_cast<LiquidCrystal*>(_impl)

namespace lcd
{


qc1602a::qc1602a(int rs, int rw, int e, int a, int d4, int d5, int d6, int d7)
  : _impl(new LiquidCrystal(rs, rw, e, d4, d5, d6, d7))
  , _backlight(a)
{
  pinMode(_backlight, OUTPUT);
  digitalWrite(_backlight, HIGH);
  IMPL->begin(16,2);              // columns, rows.  use 16,2 for a 16x2 LCD, etc.
  IMPL->clear();                  // start with a blank screen
}


qc1602a::~qc1602a(void)
{ delete IMPL; }


void qc1602a::set_backlight(bool value)
{ digitalWrite(_backlight, value ? HIGH : LOW); }


void qc1602a::print(int lin, int col, const char* val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}

void qc1602a::print(int lin, int col, int val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}


void qc1602a::print(int lin, int col, unsigned val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}


void qc1602a::print(int lin, int col, long val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}

void qc1602a::print(int lin, int col, unsigned long val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}


void qc1602a::print(int lin, int col, float val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}


void qc1602a::print(int lin, int col, double val)
{
  IMPL->setCursor(col, lin);
  IMPL->print(val);
}


} // lcd
